<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>短信发送管理</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic}/docheck/docheck.js" type="text/javascript"></script>
	<script type="text/javascript">
        $(document).ready(function() {

        });
        function page(n,s){
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }

        function showTestModal(smsContent){
            $('#smsSendContent').val(smsContent);
            $('#smsContentSize').text(smsContent.length);
            $('#smsContentModal').modal('show');
        }
        //通知 0 设置成功 1设置失败
        function checkSendStatus(type,sendStatus){
            var ids = getCheckboxValue("id");
            if(!ids){
                alert("请选择要处理的记录");
            }else {
                setSendStatus(ids, type, sendStatus);
            }
        }
		//通知 0 设置成功 1设置失败
		function setSendStatus(id, type,sendStatus){
			var actionUrl = "${ctx}/sms/smsSend/setSendStatus?ids=" + id + "&type=" + type + "&sendStatus=" + sendStatus;
			var status = "审核成功"
			if (status =="F001") {
				status = "审核失败"
			}
			top.$.jBox.confirm("确认设置状态为"+status+"吗？选择是，修改状态，选择否，取消修改","系统提示",function(v,h,f) {
				if (v == "ok") {
					$.ajax({
							   url: actionUrl,
							   success: function (data) {
								   alert(data);
								   page();
							   },
							   error: function () {
								   alert("设置失败");
							   },
							   dataType: "text"
						   });
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		}
	</script>
</head>
<body>
<ul class="nav nav-tabs">
	<li class="active"><a href="${ctx}/sms/smsSend/">信息列表</a></li>
	<!--<shiro:hasPermission name="sms:smsSend:edit"><li><a href="${ctx}/sms/smsSend/form">短信发送添加</a></li></shiro:hasPermission>-->
</ul>
<form:form id="searchForm" modelAttribute="smsSend" action="${ctx}/sms/smsSend/sented" method="post" class="breadcrumb form-search">
	<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
	<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	<input id="isEffective" name="isEffective" type="hidden" value="1"/>
	<input id="gatewayStatus" name="gatewayStatus" type="hidden" value="W"/>
	<ul class="ul-form">
		<li><label>用户ID：</label>
			<form:input path="userid" htmlEscape="false" maxlength="11" class="input-medium"/>
		</li>
		<li><label>手机号码：</label>
			<form:input path="phoneFind" htmlEscape="false" maxlength="32" class="input-medium"/>
		</li>
		<li><label>是否批量：</label>
			<form:select path="showLevel" class="input-medium">
				<form:option value="" label="全部"/>
				<form:options items="${fns:getDictList('showLevel')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
			</form:select>
		</li>
		<li><label>运营商：</label>
			<form:select path="phoneType" class="input-medium">
				<form:option value="" label="全部"/>
				<form:options items="${fns:getDictList('phone_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
			</form:select>
		</li>
		<li><label>网关编号：</label>
			<form:input path="gatewayId" htmlEscape="false" maxlength="64" class="input-medium"/>
		</li>
		<li><label>发送时间：</label>
			<input name="sendTimeQ" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
				   value="<fmt:formatDate value="${smsSend.sendTimeQ}" pattern="yyyy-MM-dd HH:mm:ss"/>"
				   onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
		</li>
		<li><label>本页号码数：</label>
			<form:input path="count" htmlEscape="false"  class="input-medium" value="${count}"/>
		</li>
		<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
	</ul>
	<ul class="ul-form">

        <%--<li class="btns"><input id="sendSuccSubmit" class="btn btn-primary" type="submit" value="发送成功" onclick="javasrcipt:checkSendStatus(1,'TOOO');" /></li>--%>
        <%--<li class="btns"><input id="sendFailSubmit" class="btn btn-primary" type="submit" value="发送失败" onclick="javasrcipt:checkSendStatus(1,'FOO1');" /></li>--%>
        <%--<li class="btns"><input id="againSubmit" class="btn btn-primary" type="submit" value="重新提交网关" onclick="javasrcipt:checkSendStatus(1,'FOO1');" /></li>--%>

		<li class="clearfix"></li>
	</ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
	<thead>
	<tr>
		<th><input type="checkbox" onclick="doCheckAll(this,'id', this.checked)"></th>
		<th>提交时间</th>
		<shiro:hasPermission name="sms:smsSend:developer">
			<th>提单号</th>
		</shiro:hasPermission>
		<th>公司名称</th>
		<th>账户名称</th>
		<th>手机号码</th>
		<th>短信内容　　　　　　　　　　　　　　　　</th>
		<th>处理时间</th>
		<th>报告时间</th>
		<th>状态</th>
		<th>重发次数</th>
		<th>重发原因</th>
		<th>网关组</th>
		<th>通道名称</th>
		<th>运营商</th>
		<th>区域</th>
	</tr>
	</thead>
	<tbody>
	<c:forEach items="${page.list}" var="smsSend">
		<tr onclick="selectTr(this, '${smsSend.id}' ,'id')">
			<td><input type="checkbox" name="id" id="${smsSend.id}" value="${smsSend.id}" onclick="if(this.checked){this.checked=false;}else{this.checked=true;}"></td>
			<td>
				<fmt:formatDate value="${smsSend.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
			</td>
			<shiro:hasPermission name="sms:smsSend:developer">
				<td>
					${smsSend.taskid}
				</td>
			</shiro:hasPermission>
			<td>
				${fns:getUserById(smsSend.userid).companyShortname}
			</td>
			<td>
				${fns:getUserById(smsSend.userid).loginName} | ${fns:getDictLabel(smsSend.smsType, 'service_id', smsSend.smsType)}
			</td>
			<td>${fn:substring(smsSend.phone, 0, 20)}...
				<a href="javascript:showTestModal('${fns:escapeHtml(smsSend.phone)}')">[更多查看]</a>
			</td>
			<td>
					${fn:substring(smsSend.smsContent, 0, 20)}...
				<a href="javascript:showTestModal('${fns:escapeHtml(smsSend.smsContent)}')">[更多查看]</a>
			</td>
			<td>
				<%--处理时间--%>
			</td>
			<td>
				<%--报告时间--%>
					<fmt:formatDate value="${smsSend.reportTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				<%--report_time--%>
			</td>
			<td>
				<%--状态--%>
					${smsSend.gatewayStatus eq 'T100' ? 'DELIVRD' : smsSend.gatewayStatus} | ${fns:getDictLabel(smsSend.userNotifyStatus,'notify_status',smsGatewayGroupRel.userNotifyStatus)}
			</td>
			<td>
				<%--重发次数--%>
				${smsSend.resendTimes}
			</td>

			<td>
					${smsSend.resendTimes}
				<%--重发原因--%>
			</td>
			<td>
				<%--网关组--%>
				${fns:getGatewayGroupById(smsSend.gatewayGroup).name}
			</td>

			<td>
			<%--通道名称--%>
				${fns:getGatewayByCode(smsSend.gatewayId).gwName}
			</td>
			<td>
				<%--运营商--%>
				${fns:getDictLabel(smsSend.phoneType,'phone_type',smsGatewayGroupRel.phoneType)}
			</td>

			<td>
			<%--区域--%>
				${fns:getDictLabel(fn:substring(smsSend.phoneArea,0,2),'phone_province',smsSend.phoneArea)}
			</td>

		</tr>
	</c:forEach>
	</tbody>
</table>
<div class="pagination">${page}</div>

<!-- 短信内容 -->
<div class="modal fade" style="display:none;" id="smsContentModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close"
						data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					短信内容
				</h4>
			</div>
			<div class="modal-body">
				<form id="gateWaySendForm" class="form-horizontal">
					<div class="control-group">
						<div class="controls1">
							<textarea style="width:498px;" readonly="readonly" name="smsSendContent" id="smsSendContent" rows="6" cols="8"></textarea>
							共 <label name="smsContentSize" id="smsContentSize"></label>  个字。
						</div>
					</div>
				</form>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
<!-- END -->

</body>
</html>